package com.lab.servlet;

import java.io.IOException;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import net.sf.json.JSONArray;

import com.lab.dao.StudentDao;
import com.lab.dao.impl.StudentDaoImpl;
import com.lab.po.Student;

/**
 * Servlet implementation class ShowStuPwdAjax
 */
@WebServlet("/showStuPwdAjax")
public class ShowStuPwdAjax extends HttpServlet {
	private static final long serialVersionUID = 1L;
       
    /**
     * @see HttpServlet#HttpServlet()
     */
    public ShowStuPwdAjax() {
        super();
        // TODO Auto-generated constructor stub
    }

	/**
	 * @see HttpServlet#doGet(HttpServletRequest request, HttpServletResponse response)
	 */
	protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		doPost(request,response);
	}

	/**
	 * @see HttpServlet#doPost(HttpServletRequest request, HttpServletResponse response)
	 */
	protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		String stuid=request.getParameter("stuid");
		StudentDao studentdao=new StudentDaoImpl();
		Map map=new HashMap();
		if(stuid!=null && !stuid.equals("")){
			map.put("stuid",stuid);
		}
		List<Student> studentList=studentdao.selectStudentByCon(map);
		JSONArray jsonArray=JSONArray.fromObject(studentList);
		response.getWriter().write(jsonArray.toString());
	}

}
